#ifndef SERVOCONTROLLER_H
#define SERVOCONTROLLER_H

#include <QObject>
#include <QSerialPort>

class ServoController : public QObject
{
    Q_OBJECT

public:
    explicit ServoController(QObject *parent = nullptr);
    ServoController(const QString &port, int baudrate, QObject *parent = nullptr);
    virtual ~ServoController();  

    bool open();
    void close();
    bool sendData(const QString &data);
    void W_on();
    void B_on();
    void DCT_on();
    void DCT_off();

signals:
    void receivedCommand(quint8 state, quint8 row, quint8 col);

private slots:
    void readData();

private:
    QSerialPort *serialPort;
    QString portName;
    int baudRate;
    QByteArray receiveBuffer;  // 接收缓冲区
};

#endif // SERVOCONTROLLER_H